from zhipuai import ZhipuAI

client = ZhipuAI(api_key="802580dc2848935a189cac7ae33af594.2SWW3iXZKAOPqXXF")

tools = [{
    "type": "web_search",
    "web_search": {
        "enable": True #默认为关闭状态（False） 禁用：False，启用：True。
    }
}]

messages = [{
    "role": "user",
    "content": "中国 2024 年一季度的GDP是多少 "
}]

response = client.chat.completions.create(
    model="glm-4",
    messages=messages,
    tools=tools
)
print(response.choices[0].message)